package com.bwei.topnews.adapter;

import android.content.Context;
import android.view.Gravity;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.bwei.topnews.MainActivity;
import com.bwei.topnews.R;
import com.bwei.topnews.app.MyApplication;
import com.bwei.topnews.base.MyBaseAdapter;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by qwe on 2016/11/10.
 */
public class MyChannelAdapter extends MyBaseAdapter<String> {

    private ImageView iv_channel_xx;
    private TextView tv_channel_title;

    public MyChannelAdapter(MainActivity context, ArrayList<String> list) {
        super(list, context);
    }

    @Override
    protected View initGetView(int position, View convertView, ViewGroup parent) {
            convertView = View.inflate(context, R.layout.mychannel_text,null);
            iv_channel_xx = (ImageView) convertView.findViewById(R.id.iv_channel_xx);
            tv_channel_title = (TextView) convertView.findViewById(R.id.tv_channel_title);
            tv_channel_title.setText(list.get(position).substring(0,list.get(position).indexOf(":")));
        if(MyApplication.channelLongClick){
            if(position!=0) {
                iv_channel_xx.setVisibility(View.VISIBLE);
            }
        }else{
            iv_channel_xx.setVisibility(View.GONE);
        }
        return convertView;
    }
}
